import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProWorklogVO, ProWorklogForm, ProWorklogQuery, ProWorklogAuditQuery, ProWorklogAuditVO } from '@/api/project/log/worklog/types';
import { ProWorklogAuditBo } from '@/api/project/log/worklog/types';

/**
 * 查询工作日志列表
 * @param query
 * @returns {*}
 */

export const listProWorklog = (query?: ProWorklogQuery): AxiosPromise<ProWorklogVO[]> => {
  return request({
    url: '/pro/worklog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工作日志详细
 * @param id
 */
export const getProWorklog = (id: string | number): AxiosPromise<ProWorklogVO> => {
  return request({
    url: '/pro/worklog/' + id,
    method: 'get'
  });
};

/**
 * 新增工作日志
 * @param data
 */
export const addProWorklog = (data: ProWorklogForm) => {
  return request({
    url: '/pro/worklog',
    method: 'post',
    data: data
  });
};

/**
 * 批量新增工作日志
 * @param data
 */
export const batchAddProWorklog = (data: ProWorklogAuditBo): AxiosPromise<number> => {
  return request({
    url: '/pro/worklog/batch',
    method: 'post',
    data: data
  });
};

/**
 * 修改工作日志
 * @param data
 */
export const updateProWorklog = (data: ProWorklogForm) => {
  return request({
    url: '/pro/worklog',
    method: 'put',
    data: data
  });
};

/**
 * 删除工作日志
 * @param id
 */
export const delProWorklog = (id: string | number | Array<string | number>) => {
  return request({
    url: '/pro/worklog/' + id,
    method: 'delete'
  });
};

/**
 * 查询最近提交的工作日志打包记录
 */
export const recentAuditList = (): AxiosPromise<any> => {
  return request({
    url: '/pro/worklog/audit/recentList',
    method: 'get'
  });
};

/**
 * 根据审核ID查询工作日志列表
 * @param auditId 审核ID
 */
export const getWorklogsByAuditId = (auditId: string | number): AxiosPromise<any> => {
  return request({
    url: `/pro/worklog/logList/${auditId}`,
    method: 'get'
  });
};

/**
 * 批量修改工作日志
 * @param data 工作日志列表
 */
export const batchEditProWorklog = (data: any[]) => {
  return request({
    url: '/pro/worklog/batch',
    method: 'put',
    data: data
  });
};

/**
 * 查询工作日志审核列表
 * @param query 查询参数
 */
export const listProWorklogAudit = (query?: ProWorklogAuditQuery): AxiosPromise<any> => {
  return request({
    url: '/pro/worklog/audit/list',
    method: 'get',
    params: query
  });
};
